package com.acme.bankapp.service.email;

import java.io.*;
import java.util.*;

/**
 * Class provides queue
 * @author alex
 */
@SuppressWarnings("serial")
public class Queue implements Serializable {
	private List<Email> list;
	
	/**
	 * The default constructor
	 */
	public Queue() {
		this.list = new LinkedList<Email>();
	}
	
	/**
	 * @param email the email
	 */
	public synchronized void add(Email email) {
		this.list.add(email);
	}
	
	/**
	 * @return the email
	 */
	public synchronized Email get() {
		return this.list.remove(0);
	}
	
	/**
	 * @return whether the queue is empty
	 */
	public synchronized boolean isEmpty() {
		return this.list.isEmpty();
	}
}
